﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CameraRevolve : MonoBehaviour
{
    public Transform target;
    public float rotationSpeed = 10;
    public float distance = 5.0f;
    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        if (target != null)
        {
            transform.RotateAround(target.position, Vector3.up, rotationSpeed * Time.deltaTime);

            Vector3 direction = (transform.position - target.position).normalized * distance;
            transform.position = target.position + direction;

            transform.LookAt(target);
        }
    }

}
